<?php

//Begin//Xay dung chuoi XML chua gia tri
$v_list_xml_tag = "";
if(isset($_REQUEST['hdn_list_xml_tag'])){
	$v_list_xml_tag = $_REQUEST['hdn_list_xml_tag'];
}
$v_list_xml_value = "";
if(isset($_REQUEST['hdn_list_xml_value'])){
	$v_list_xml_value = $_REQUEST['hdn_list_xml_value'];
}
$v_xml_str = '<?xml version="1.0" encoding="UTF-8"?><root><data_list>';
for ($i=0; $i<_list_get_len($v_list_xml_tag,_CONST_SUB_LIST_DELIMITOR); $i++){
	$v_xml_str = $v_xml_str ."<"._list_get_at($v_list_xml_tag,$i,_CONST_SUB_LIST_DELIMITOR).">";
	$v_xml_str = $v_xml_str .trim(_replace_XML_bad_char(_list_get_at($v_list_xml_value,$i,_CONST_SUB_LIST_DELIMITOR)));
	$v_xml_str = $v_xml_str ."</"._list_get_at($v_list_xml_tag,$i,_CONST_SUB_LIST_DELIMITOR).">";
}
$v_xml_str = $v_xml_str . "</data_list></root>";

$v_staff_id = intval($_SESSION['staff_id']);
//$v_staff_id = -10;

$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];

$v_from_receive_date = "";
if(isset($_REQUEST['from_receive_date'])){
	$v_from_receive_date = _ddmmyyyy_to_yyyymmdd($_REQUEST['from_receive_date']);
}
$v_to_receive_date = "";
if(isset($_REQUEST['to_receive_date'])){
	$v_to_receive_date = _ddmmyyyy_to_yyyymmdd($_REQUEST['to_receive_date']);
}

$v_from_result_date = "";
if(isset($_REQUEST['from_appointed_date'])){
	$v_from_result_date = _ddmmyyyy_to_yyyymmdd($_REQUEST['from_appointed_date']);
}

$v_to_result_date = "";
if(isset($_REQUEST['to_appointed_date'])){
	$v_to_result_date = _ddmmyyyy_to_yyyymmdd($_REQUEST['to_appointed_date']);
}
$v_cmt_num = 0;
//if(isset($_REQUEST['so_chung_minh'])){
	//$v_cmt_num = $_REQUEST['so_chung_minh'];
 //}
$v_status_list = 'CAP_PHEP';

if(isset($_REQUEST['offset'])){
	$v_offset = $_REQUEST['offset'];
}else{
	$v_offset=1;
}
$v_limit = 10;

if(isset($_REQUEST['hdn_page'])){
	$v_page=$_REQUEST['hdn_page'];
}else{
	$v_page=1;
}

$v_filter_value = '';
if(isset($_REQUEST['registor_name'])){
	//$v_filter_value = $_REQUEST['registor_name'];
	$rax = new RAX(); 
	$rec = new RAX(); 
	$rax->open($v_xml_str);
	$rax->record_delim = "data_list";
	$rax->parse();
	$rec = $rax->readRecord(); 
	$row = $rec->getRow();
	$v_filter_value = _restore_XML_bad_char($row["registor_name"]);
}
$v_cmt_num = 0;
if(isset($_REQUEST['so_chung_minh'])){
	//$v_filter_value = $_REQUEST['registor_name'];
	$rax = new RAX(); 
	$rec = new RAX(); 
	$rax->open($v_xml_str);
	$rax->record_delim = "data_list";
	$rax->parse();
	$rec = $rax->readRecord(); 
	$row = $rec->getRow();
	$v_cmt_num = $row["so_chung_minh"];
}
$v_record_code= '';
if(isset($_REQUEST['record_code'])){
	//$v_record_code = $_REQUEST['record_code'];
	$rax = new RAX(); 
	$rec = new RAX(); 
	$rax->open($v_xml_str);
	$rax->record_delim = "data_list";
	$rax->parse();
	$rec = $rax->readRecord(); 
	$row = $rec->getRow();
	$v_record_code = _restore_XML_bad_char($row["record_code"]);
}

$v_filter_xml_tag = '';
if(isset($_REQUEST['filter_xml_tag'])){
	$v_filter_xml_tag = $_REQUEST['filter_xml_tag'];
}
//echo 'v_xml_str'.htmlspecialchars($v_xml_str); 
if(_is_sqlserver()){
	$sql = "Exec Onegate_ArchiveRecordGetPerPage";
	$sql = $sql . " " . $v_staff_id ;
	$sql = $sql . ",'" . $v_recordtype_filter . "'" ;
	$sql = $sql . ",'" .$v_from_receive_date. "'" ;
	$sql = $sql . ",'" .$v_to_receive_date. "'" ;
	$sql = $sql . ",'" .$v_from_result_date. "'" ;
	$sql = $sql . ",'" .$v_to_result_date. "'" ;	
	$sql = $sql . ",'" .$v_filter_value. "'" ;	
	$sql = $sql . ",'" . $v_filter_xml_tag."'" ;
	$sql = $sql.",".$v_page;
	$sql = $sql.",".$v_limit;
	$sql = $sql.",'".$v_record_code."'";
	//$sql = $sql.",".$v_cmt_num;
	//$sql = $sql.",".$v_shk_num;
	//echo $sql; //exit;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$arr_all_record = $ado_conn->GetAll($sql);
	$v_total_record = $arr_all_record[0]['TOTAL_RECORD'];
	//var_dump($arr_all_record);
}
?>